/*2S7LXljdWdGhrCxZ1MFl4i0/jcYg0CI/M/l35xRmsHHDM270ypZGxQFjXbKKRAXA*/
import React, { Component } from 'react';
import {base,ajax, toast, deepClone, createPage, getMultiLang } from 'nc-lightapp-front';
import '../../../../css/searchModal/index.less';

const { NCDatePicker:DatePicker,NCRow:Row,NCCol:Col,NCTable:Table,NCSelect:Select,
    NCCheckbox:Checkbox,NCNumber,NCInput: Input
} = base;


const NCOption = Select.NCOption;
// const format = 'YYYY-MM-DD';
// const Timeformat = "YYYY-MM-DD HH:mm:ss";

import NewModal from '../modal'
import {
    renderMoneyType,
    getSubjectVersion,
    returnMoneyType,
    createReferFn,
    getCheckContent, businessUnit, getReferDetault, delKeyOfObj, getAllState, clickPlanEve, renderMiddleTxt
} from '../../../../common/modules/modules';
import SubjectVersion from "../../../../common/modules/subjectVersion";
import DateGroup from '../../../../common/modules/dateGroup';
import CheckBoxCells from '../../../../common/modules/checkBox';
import {handleValueChange} from '../../../../common/modules/handleValueChange'
import FourCheckBox from '../../../../common/modules/fourCheckBox'

import initTemplate from '../../../../modalFiles/initTemplate';
import {handleNumberInput} from "../../../../common/modules/numberInputFn";
// import ReferWraper from '../../../../../public/components/ReferWraper'
import FormLabel from '../../../../../public/components/FormLabel';
// import ReferLoader from '../../../../../public/ReferLoader/index.js';
import {voucherHeightConfig} from '../../../../../export/pub/tinperNext/index.js';
import { drawAssidCell, drawSearchObj } from '../../../../common/modules/drawAssidCell';
class CentralConstructorModal extends Component {

	constructor(props) {
		super(props);
		this.state=getAllState(this.getInitState());
		this.balanceMoney = this.balanceMoney.bind(this);//余额范围输入触发事件

        this.sureHandle = this.sureHandle.bind(this);
        this.closeNewModal = this.closeNewModal.bind(this);
        this.outInputChange = this.outInputChange.bind(this);



        this.renderTableFirstData = this.renderTableFirstData.bind(this);// table渲染初始的数据
        // this.handleSearchObj = this.handleSearchObj.bind(this);//查询对象 选择触发事件
		// this.findByKey = this.findByKey.bind(this);
		// this.renderSearchRange = this.renderSearchRange.bind(this);//根据'查询对象'的选择来对应渲染'查询范围'的组件
		// this.renderRefPathEle = this.renderRefPathEle.bind(this);//根据传进来的url渲染对应的参照组件
		this.handleCheckbox = this.handleCheckbox.bind(this);//计算小计	包含下级复选框的点击事件

		this.handleValueChange = handleValueChange.bind(this);
		this.searchId = '20028001query';
        this.handleNumberInput = handleNumberInput.bind(this);
        props.use.search(this.searchId);
	}
    //获取初始化state
	getInitState = () =>{
        let initState = {
		    // json: {},
            dateInputPlaceholder: '', ///* 国际化处理： 选择日期*/
            supplierType: '', //第二层弹框中的'供应商类型'的值
            assistDateValue: '', //辅助参照中的日期的state值
            assistDateTimeValue: '', //辅助参照中的日期+时分秒的state值
            stringRefValue: '', //辅助参照中的字符的state值
            numberRefValue: '',//辅助参照中的数值的state值
            numberRefValueInteger: '',//辅助参照中整数值
            booleanValue: '', //辅助参照中布尔值
            groupCurrency: true,//是否禁止"集团本币"可选；true: 禁止
            globalCurrency: true, //是否禁止"全局本币"可选；true: 禁止
            showRadio: true,//控制是否显示"会计期间"的但选框；false: 不显示
            appcode: '20028001',
            isShowUnit:false,//是否显示业务单元
            busiDate: '', //业务日期

            versiondate: '', //制单日期，后续要用下拉选
            versionDateArr: [], //存放请求账簿对应的版本数组


            /*****会计期间******/
            selectionState: 'true', //按期间查询true，按日期查询false
            startyear: '', //开始年
            startperiod: '',  //开始期间
            endyear: '',  //结束年
            endperiod: '',   //结束期间
            /*****日期******/
            begindate: '', //开始时间
            enddate: '', //结束时间
            rangeDate: [],//时间显示

            renderData: [], //我的弹框里数据
			innerSelectName: [], //"查询范围"里存放的数据
            innerSelectData: [], //最里层选择数据的项
            rangefrom: '', //余额范围起始值
            rangeto: '', //余额范围结束值


            listItem:{},//业务单元中模板数据对应值

			selectedSort: 'true',//排序方式
			selectedShowType: 'false', //多主题显示方式
			doubleCell: false, // 多业务单元合并
			allLast: true, // 所有末级是否选中
			outProject: false, //表外科目是否选中
			multiProjectMerge: true, //多主题合并
			subjectShow: true, //按主题列示
			balanceMoneyLeft: '', //余额范围左边输入框
            balanceMoneyRight: '', //余额范围右边输入框
            pk_accperiodscheme: '',//会计期间参数
			accountingbook: {
				refname: '',
				refpk: '',
			},  //核算账簿
			accountingUnit: {
				refname: '',
				refpk: '',
			},  //核算账簿
			accasoa: {           //
				refname:'',
				refpk: '',
			},
			buSecond: [],
			selectedQueryValue: '0', //查询方式单选
			selectedCurrValue: '1', //返回币种单选
			ismain: '0', // 0主表  1附表
			currtype: '',      //选择的币种/* 国际化处理： 本币*/
			currtypeName: '',  //选择的币种名称/* 国际化处理： 本币*/
			currtypeList: [],  //币种列表
			defaultCurrtype: {         //默认币种
				name: '',
				pk_currtype: '',
			},
			checkbox: {
				one: false,
				two: false,
				three: false,
			},
			balanceori: '-1', //余额方向
			startlvl: '1', //开始级次
			endlvl: '1',  //结束级次
			startcode: {
				refname:'',
				refpk: '',
			}, //开始科目编码
			endcode: {
				refname:'',
				refpk: '',
			},    //结束科目编码

			isleave: false, //是否所有末级
			isoutacc: false, //是否表外科目
			includeuntally: false, //包含凭证的4个复选框 未记账
			includeerror: false, //包含凭证的4个复选框 错误
			includeplcf: true, //包含凭证的4个复选框 损益结转
			includerc: false, //包含凭证的4个复选框 重分类
			mutibook: 'N', //多主体显示方式的选择
			disMutibook: true, //多主体显示是否禁用
			currplusacc: 'Y', //排序方式
			disCurrplusacc: true, //排序方式是否禁用
			showzerooccur: false, //无发生不显示
			upLevelSubject: false, //显示上级科目
			showzerobalanceoccur: true, //无余额无发生不显示
			sumbysubjtype: false, //科目类型小计
			disSumbysubjtype: false, //科目类型小计是否禁用
			twowaybalance: false, //借贷方显示余额
			showSecond: false, //是否显示二级业务单元
			multbusi: false, //多业务单元复选框
			start: {},  //开始期间
			end: {}, //结束期间
			isversiondate: false,
            indexArr: [], //存放"查询对象"已经选择的索引


			//tabel组件头部
			//table的数据
			tableSourceData: [],

            selectRow: [],//存放所选择的不是参照类型的数据
            page: 0//第二个弹框中要显示的行内容索引
		}
        return initState;
    }
    //设置初始state,切换预置方案时用到
	setInitState = () => {
        let initState = this.getInitState()
		delKeyOfObj(initState, ['currtype', 'currtypeName', 'currtypeList', 'tableSourceData'])
		this.setState(initState);
        this.renderTableFirstData(10);
		getReferDetault(this, true, {
            businessUnit,
            getCheckContent
        }, 'assistPropertyBalance')
    }
    componentWillMount() {
        let callback= (json) =>{
            this.setState({
                json:json,
                dateInputPlaceholder: json['20028001-000003'], ///* 国际化处理： 选择日期*/
                currtype: json['20028001-000004'],      //选择的币种/* 国际化处理： 本币*/
                currtypeName: json['20028001-000004'],  //选择的币种名称/* 国际化处理： 本币*/
            },()=>{
                // initTemplate.call(this, this.props);
            })
        }
        getMultiLang({moduleId:['20028001', 'dategroup', 'checkbox', 'fourcheckbox', 'subjectversion', 'childmodules'],domainName:'gl',currentLocale:'simpchn',callback});
        this.getCurrtypeList();
        this.renderTableFirstData(10);
    }

    componentDidMount() {
        setTimeout(() => getReferDetault(this, true, {
            businessUnit,
            getCheckContent
        }, 'assistPropertyBalance'),0);
        setTimeout(() => initTemplate.call(this,this.props), 0)
    }
    // handleSearchObj(values, record){//查询对象选择具体科目
    //     let value = JSON.parse(values)
    // 	let { tableSourceData, selectRow } = this.state;
    //     let originData = this.findByKey(record.key, tableSourceData);
    //     originData.selectCell = value;
    //     record.selectCells = [];
    //     record.selectRange = [];
    //     if(value.refpath ){
    //         originData.type = 'referpath';
    //         originData.searchRange = value.refpath;
	// 	}else if(value.datatype === '1'){//字符
    //         originData.type = 'string';
    //     } else if(value.datatype === '4'){//整数
    //         originData.type = 'integer';
    //     } else if(value.datatype === '31'){//数值(小数)
    //         originData.type = 'number';
    //     } else if(value.datatype === '32'){//布尔
    //         originData.type = 'boolean';
    //     } else if(value.datatype === '33'){//日期
    //         originData.type = 'date'
    //     } else if(value.datatype === '34'){//日期+时分秒时间
    //         originData.type = 'dateTime'
    //     } else if(value.attr){
    //         originData.selectCellAttr = [...value.attr];
    //         originData.type = 'modal'
	// 	} else {
    //         originData.type = ''
	// 	}
	// 	let newSelectRow = [...selectRow];
    //     newSelectRow[record.key] = record;
    // 	this.setState({
    //         tableSourceData,
    //         selectRow: newSelectRow,
	// 	})
	// }
    handleCheckbox(key, record){//计算小计	包含下级复选框的点击事件
    	let {tableSourceData} = this.state;
        record[key] = record[key] === 'N' ? 'Y' : 'N';
        this.setState({
            tableSourceData
		})

	}
    // findByKey(key, rows) {
    //     let rt = null;
    //     let self = this;
    //     rows.forEach(function(v, i, a) {
    //         if (v.key == key) {
    //             rt = v;
    //         }
    //     });
    //     return rt;
    // }
    // dateRefChange = (key, value, record) => {
    //     //('dateRefChange>',value, record);
    //     let length = record.selectCell.inputlength;
    //     let exeReg = new RegExp("^.{0," + length + "}$");
    //     let result = exeReg.exec(value);
    //     if(result && key === 'stringRefValue'){
    //         record.selectRange = result[0]
    //         this.setState({
    //             [key]: result[0]
    //         })
    //     }else {
    //         record.selectRange = value
    //         this.setState({
    //             [key]: value
    //         })
    //     }
    // }
    // numberRefChange = (key, value, record, param) => {
    //     //('numberRefChange>>', value, record);
    //     this.handleNumberInput(key, value, param, record);
    //     setTimeout(() => record.selectRange = this.state[key], 0)

    // }
    // renderSearchRange(record, fieldid){//根据'查询对象'的选择来对应渲染'查询范围'的组件
    // 	//('renderSearchRange>', record);
    // 	switch(record.type){
	// 		case "referpath":
	// 			let refPathEle = this.renderRefPathEle(record, fieldid);
	// 			//('refPathEle>>', refPathEle);
	// 			return refPathEle;
    //         case 'date':
    //             return (
    //                 <DatePicker
    //                     fieldid={fieldid}
    //                     format={format}
    //                     value={this.state.assistDateValue}
    //                     placeholder={this.state.dateInputPlaceholder}
    //                     onChange={(value) => this.dateRefChange('assistDateValue', value, record)}
    //                 />
    //             );
    //         case 'string':
    //             return <Input
    //                 fieldid={fieldid}
    //                 value={this.state.stringRefValue}
    //                 onChange={(value) => this.dateRefChange('stringRefValue', value, record)}
    //             />;
    //         case 'number':
    //             return <Input
    //                 fieldid={fieldid}
    //                 value={this.state.numberRefValue}
    //                 onChange={(value) => this.numberRefChange('numberRefValue', value, record, 'assistBalance') }
    //             />;
    //         case 'integer'://整数
    //             return <Input
    //                 fieldid={fieldid}
    //                 value={this.state.numberRefValueInteger}
    //                 onChange={(value) => this.numberRefChange('numberRefValueInteger', value, record, 'assistBalanceInteger') }
    //             />;
    //         case 'boolean'://布尔
    //             return <Select
    //                 fieldid={fieldid}
    //                 value={this.state.booleanValue}
    //                 className='search-boolean'
    //                 onChange={(value)=>{
    //                     //('NCSelect>>>', value);
    //                     this.dateRefChange('booleanValue', value, record)
    //                 }}
    //             >
    //                 <NCOption value="Y">{this.state.json['20028001-000026']}</NCOption>{/* 国际化处理： 是*/}
    //                 <NCOption value="N">{this.state.json['20028001-000027']}</NCOption>{/* 国际化处理： 否*/}
    //                 <NCOption value="">{this.state.json['20028001-000028']}</NCOption>{/* 国际化处理： 空*/}
    //             </Select>;
    //         case 'dateTime'://日期+时分秒
    //             return (
    //                 <DatePicker
    //                     fieldid={fieldid}
    //                     showTime={true}
    //                     format={Timeformat}
    //                     value={this.state.assistDateTimeValue}
    //                     placeholder={this.state.dateInputPlaceholder}
    //                     onChange={(value) => this.dateRefChange('assistDateTimeValue', value, record)}
    //                 />
    //             );
	// 		case 'modal':
    //             //('????', record, record.selectCell, record.selectCellAttr);
    //             let attrObj = record.selectCellAttr;
    //             let { tableSourceData } = this.state;
    //             let showArr = [];
    //             attrObj && attrObj.map((item) => {
    //                 if (item) {
    //                     item.itemKey = record.key;
    //                 }
    //                 if (item.select) {
    //                     let showitem = "【" + item.name + ":";
    //                     if (!item.selectName || item.selectName === '' || (Array.isArray(item.selectName) && item.selectName.length == 0)) { // 不选值，即为全选
    //                         showitem += "ALL";
    //                     } else if (item.enums) { // 枚举类型的，取枚举的name
    //                         item.enums.map((enumcell, index) => {
    //                             if (enumcell.value === item.selectName) {
    //                                 showitem += enumcell.name;
    //                             }
    //                         })
    //                     } else { // 参照的单选和多选
    //                         if (Array.isArray(item.selectName)) {
    //                             showitem += item.selectName.join(',');
    //                         } else {
    //                             showitem += item.selectName;
    //                         }
    //                     }
    //                     showitem += "】";
    //                     showArr.push(showitem);
    //                 }
    //             })
    //             //('showArr:::', showArr);
	// 			return (
    //                 <ReferWraper
    //                     // outStyle={{width: '200px', marginLeft: '10px'}}
    //                     fieldid={fieldid}
    //                     placeholder = {record.selectCell && record.selectCell.name}
    //                     display={showArr.join('')}  //显示值
    //                     // disabled={dis}
    //                     onClick={() => this.setState({
    //                         page: record.key
    //                     },()=>{
    //                         this.NewModal.show();
    //                     })}
    //                 />
	// 			);
	// 		default:
	// 			return <Input fieldid={fieldid} disabled/>;
	// 	}
	// }
   
	// renderRefPathEle(record, fieldid){//根据传进来的url渲染对应的参照组件
    // 	//('renderRefPathEle>',record, record.selectCell);
    //     //带有参照的
	// 	//('state>>>>',record, record.selectCell, record.selectCell.pk_checktype, !this.state[record.selectCell.pk_checktype]);
	// 	let mybook;
    //     let objKey = record.key + record.selectCell.pk_checktype;
    //     let referUrl = record.selectCell.refpath+".js";
	// 	// if(!this.state[objKey]){//undefined
	// 	// 	//('createScript:', this.state);
	// 	// 	{createScript.call(this,record.selectCell.refpath+".js",objKey)}

	// 	// }else{
	// 		//('rendertableRight>:::', this.state, this.state[objKey]);
    //         let pkOrgParam = this.state.buSecond.length > 0 ? this.state.buSecond[0].refpk : this.state.unitValueParam; //this.state.accountingbook[0].nodeData ? this.state.accountingbook[0].nodeData.pk_corp : this.state.accountingbook[0].pk_corp;
    //         let options = {
    //             fieldid: fieldid,
    //             tag: referUrl,
    //             refcode: referUrl,
    //             value: record.selectCells,
    //             isMultiSelectedEnabled:true,
    //             "isShowDisabledData": true,
    //             queryCondition:() => {
    //                 return {
    //                     "pk_accountingbook": this.state.accountingbook[0] && this.state.accountingbook[0].refpk,
    //                     "pk_org": pkOrgParam,
    //                     "isDataPowerEnable": 'Y',
    //                     "DataPowerOperationCode" : 'fi',
    //                     "dateStr": this.state.isversiondate ? this.state.versiondate : this.state.busiDate
    //                 }
    //             },
    //             onChange: (v)=>{
    //                 //('innerChaa:', v, this.state.tableSourceData);
    //                 let {tableSourceData} = this.state;
    //                 let refpkArr = [];
    //                 let selectCell = [];
    //                 v.forEach((item)=>{
    //                     //('vFormach::', item);
    //                     refpkArr.push(item.refpk);
    //                     selectCell.push(item);
    //                 })
    //                 let pk_checkvalue = refpkArr.join(',')
    //                 record.selectRange = pk_checkvalue;
    //                 record.selectCells = selectCell
    //                 this.setState({
    //                     tableSourceData
    //                 })
    //             }
    //         };
    //         let newOPtions = {}
    //         if(record.selectCell.classid=='b26fa3cb-4087-4027-a3b6-c83ab2a086a9'||record.selectCell.classid=='40d39c26-a2b6-4f16-a018-45664cac1a1f') {//部门，人员
    //             //('recorddd>>???', record);
    //             newOPtions = {
    //                 ...options,
    //                 "unitValueIsNeeded":false,
    //                 queryCondition:() => {
    //                     return {
    //                         "pk_accountingbook": this.state.accountingbook[0] && this.state.accountingbook[0].refpk,
    //                         "pk_org": pkOrgParam,
    //                         "isDataPowerEnable": 'Y',
    //                         "DataPowerOperationCode" : 'fi',
    //                         "dateStr": this.state.isversiondate ? this.state.versiondate : this.state.busiDate,
    //                         "busifuncode":"all",
    //                         isShowDimission:true
    //                     }
    //                 },
    //                 isShowUnit:true,
    //                 unitProps:{
    //                     refType: 'tree',
    //                     refName: this.state.json['20028001-000015'], ///* 国际化处理： 业务单元*/
    //                     refCode: 'uapbd.refer.org.BusinessUnitTreeRef',
    //                     rootNode:{refname:this.state.json['20028001-000015'],refpk:'root'}, ///* 国际化处理： 业务单元*/
    //                     placeholder:this.state.json['20028001-000015'], ///* 国际化处理： 业务单元*/
    //                     queryTreeUrl: '/nccloud/uapbd/org/BusinessUnitTreeRef.do',
    //                     treeConfig:{name:[this.state.json['20028001-000016'], this.state.json['20028001-000017']],code: ['refcode', 'refname']}, ///* 国际化处理： 编码,名称*/
    //                     isMultiSelectedEnabled: false,
    //                     //unitProps:unitConf,
    //                     isShowUnit:false
    //                 },
    //                 unitCondition:{
    //                     pk_financeorg: pkOrgParam,
    //                     'TreeRefActionExt':'nccloud.web.gl.ref.OrgRelationFilterRefSqlBuilder'
    //                 },
    //             }
    //         }else if(record.selectCell.classid && record.selectCell.classid.length === 20){
    //             newOPtions = {
    //                 ...options,
    //                 pk_defdoclist: record.selectCell.classid
    //             }
    //         }else {
    //             newOPtions = {
    //                 ...options
    //             }
    //         }
    //         mybook =  (
	// 			<Row className="tableselectItem">
	// 				<div className='tablerefercon'>
    //                     <ReferLoader {...newOPtions}/>
	// 				</div>
	// 			</Row>
	// 		);
	// 	// }
	// 	return mybook;
	// }
    renderTableFirstData(length){
    	let firstData = [];
    	for(let i=0; i<length; i++){
    		let obj = {};
    		obj.searchObj = [];
            obj.searchRange = '';
            obj.showLocal = 'N';//显示位置
            obj.accele = 'N';//小计
            obj.includesub = 'N';//包含下级
			obj.key = i;
            firstData.push(obj);
		}
		this.setState({
            tableSourceData: [...firstData]
		})
	}

	handleRadioChange(value) {
		this.setState({selectedQueryValue: value});
	}

	handleRadioCurrChange(value) {
		this.setState({selectedCurrValue: value});
	}
	
	//排序方式单选变化
	handleCurrplusacc(value) {
		this.setState({currplusacc: value});
	}




	getCurrtypeList = () => {//获取"币种"接口
		let self = this;
		let url = '/nccloud/gl/voucher/queryAllCurrtype.do';
		// let data = '';
		let data = {"localType":"1", "showAllCurr":"1"};

		ajax({
		    loading: true,
		    url,
		    data,
		    success: function (res) {
		        const { data, error, success } = res;
		        if(success){
					self.setState({
						currtypeList: data,
					})
		            
		        }else {
		            toast({ content: error.message, color: 'warning' });
		        }
		    },
		    error: function (res) {
		    	toast({ content: res.message, color: 'warning' });
		        
		    }
		});

	}

	handleBalanceoriChange(value) {
		this.setState({balanceori: value});
	}


    handleCurrtypeChange = (keyParam, value) => {
        this.setState({
            [keyParam]: value,
        });
    }


	handleIsmainChange(value) {
		this.setState({
			ismain: value,
		})
	}

	//开始级次变化
	handleStartlvlChange(value) {
		//(value)
		this.setState({
			startlvl: value,
		})
	}
	
	//结束级次变化
	handleEndlvlChange(value) {
		//(value)
		this.setState({
			endlvl: value,
		})
	}
	
	//科目版本下拉变化
	handleVersiondateChange(value) {
    	//('handleVersiondateChange>', value);
		this.setState({
			versiondate: '2018-5-31'// value,
		})
	}
	
	//所有末级复选框变化
	onChangeIsleave(e) {
	    //(e);
	    let isleave = deepClone(this.state.isleave);
	   
	    this.setState({isleave: e});
	}

	//表外科目复选框变化
	onChangeIsoutacc(e) {  
	    this.setState({isoutacc: e});
	}

	//启用科目版本复选框变化
	onChangeIsversiondate(e) {  
	    this.setState({isversiondate: e});
	}


	//未记账凭证复选框变化
	onChangeIncludeuntally(e) {  
	    this.setState({includeuntally: e});
	}

	//错误凭证复选框变化
	onChangeIncludeerror(e) {
		this.setState({includeerror: e});
	}

	//损益结转凭证复选框变化
	onChangeIncludeplcf(e) {
		this.setState({includeplcf: e});
	}

	//损益结转凭证复选框变化
	onChangeIncluderc(e) {
		this.setState({includerc: e});
	}

	//多主体显示单选框变化
	handleMutibookChange(e) {
		this.setState({mutibook: e});
	}

	//无发生不显示复选框变化
	onChangeShowzerooccur = (e, key) => {
		this.setState({
			[key]: e
		});
	}

	//无余额无发生不显示复选框变化
	onChangeShowzerobalanceoccur(e) {
		this.setState({showzerobalanceoccur: e});
	}

	//无发生不显示复选框变化
	onChangeSumbysubjtype(e) {
		this.setState({sumbysubjtype: e});
	}
	//显示上级科目复选框变化
	onChangeupLevelSubject(e) {
		this.setState({upLevelSubject: e});
	}


	//借贷方显示余额复选框变化
	onChangeTwowaybalance(e) {
		this.setState({twowaybalance: e});
	}

	//合并业务单元复选框变化
	onChangeMultbusi(e) {
		let disCurrplusacc = true;
		if (e === true) {
			disCurrplusacc = false;
		} else {
			
		}

		this.setState({
			multbusi: e,
			disCurrplusacc,

		});
	}
	handleRadioSort(param){
		//('handleRadioSort>', param);
		this.setState({
			selectedSort: param
		})
	}
	handleShowType(param){
		this.setState({
			selectedShowType: param
		})
	}

	changeCheck=()=> {
		// this.setState({checked:!this.state.checked});
	}

	
	//起始时间变化
	onStartChange(d) {
		//(d)
		this.setState({
			begindate:d
		})
	}
	
	//结束时间变化
	onEndChange(d) {
		this.setState({
			enddate:d
		})
	}
	onChangeDoubleCell(param){
		this.setState({
			doubleCell: !this.state.doubleCell
		})
	}
	changeProjectStyle(param){//所有末级   表外科目选择
		if(param === 'allLast'){
			this.setState({
				allLast: !this.state.allLast
			})
		}else{
			this.setState({
				outProject: !this.state.outProject
			})
		}
	}

	handleGTypeChange =() =>{
		
	};


    outInputChange(param){
    	let nameArr = [];
        param.forEach((item) => {
            nameArr.push(item.refname);
		})
		this.setState({
            innerSelectName: [...nameArr]
		})
	}
    sureHandle(param){
        let { tableSourceData, page } = this.state
        tableSourceData[page].selectCellAttr = param;
        this.setState({
            tableSourceData,
		})
	}
    closeNewModal(param){
        let { tableSourceData, page } = this.state
        tableSourceData[page].selectCellAttr =  param
		this.setState({
            tableSourceData,
		})
    }
    balanceMoney(value, param){
        this.setState({
            [param]: value
        })
	}

    handleDateChange = (value) => {//日期: 范围选择触发事件
        //('handleDateChange:', value);
        this.setState({
            begindate: value[0],
            enddate: value[1],
            rangeDate: value
        })
    }

	renderModalList = () => {
        //('renderModalList>>', this.state)
        let { buSecond, unitValueParam, accountingbook, isversiondate, versiondate, busiDate, json } = this.state
        this.columns = [
            {
                title: (<div fieldid='searchObj'>{this.state.json['20028001-000005']}</div>),/* 国际化处理： 查询对象*/
                dataIndex: "searchObj",
                key: "searchObj",
                width: '160px',
                render: (text, record, index) => {
                    return drawSearchObj({page: this, text, record, index});
                    //('columns>>>>', text, record);
                    // let renderArr = [];
                    // text.map((item, index) => {
                    //     renderArr.push(<NCOption value={JSON.stringify(item)} key={index}>{item.name}</NCOption>)
                    // })
                    // return (
                    //     <Select
                    //         showClear={false}
                    //         fieldid='searchObj'
                    //         value={record.selectCell && record.selectCell.name}
                    //         onChange = {(value) => this.handleSearchObj(value, record)}
                    //     >
                    //         {
                    //             renderArr
                    //         }
                    //     </Select>
                    // )
                }
            },
            {
                title: (<div fieldid='searchRange'>{this.state.json['20028001-000006']}</div>),/* 国际化处理： 查询范围*/
                dataIndex: "searchRange",
                key: "searchRange",
                width: '160px',
                render: (text, record,index) => {
                    return drawAssidCell({page: this, record, index, isMultiSelectedEnabled: true, 
                        fieldid: 'searchRange', attrcode: 'selectRange', tableDataKey: 'tableSourceData', pkValueType: 'str'});
                    //('searchRangetext:::',record, record.type);
                    // let renderEle = this.renderSearchRange(record,'searchRange');
                    // return renderEle;
                }
            },
            {
                title: (<div fieldid='showLocal'>{this.state.json['20028001-000007']}</div>),/* 国际化处理： 显示位置*/
                dataIndex: "showLocal",
                key: "showLocal",
                width : '100px',
                render: (text, record) => {
                    //('showLocal>>>>', text, record)
                    return (
                        <Select
                            showClear={false}
                            fieldid='showLocal'
                            defaultValue = 'N'
                            value={record.showLocal}
                            onChange={(value) => {
                                //('showLocal:>>>',value);
                                record.showLocal = value;
                                this.setState({})
                            }}>
                            <NCOption value='Y'>{this.state.json['20028001-000024']}</NCOption>{/* 国际化处理： 表头*/}
                            <NCOption value='N'>{this.state.json['20028001-000025']}</NCOption>{/* 国际化处理： 表体*/}
                        </Select>
                    )
                }
            },
            {
                title: (<div fieldid='accele'>{this.state.json['20028001-000008']}</div>),/* 国际化处理： 计算小计*/
                dataIndex: "accele",
                key: "accele",
                width : 77,
                render: (text, record) => {
                    return <div fieldid='accele' className='text-center'><Checkbox
                        checked={record.showLocal === 'Y' ?  false : (record.accele === 'N' ? false : true) }
                        disabled={ record.selectCell &&  record.selectCell.name != ''  ?
                            (record.showLocal === 'Y' ? true : false) :
                            true
                        }
                        onChange={() => {
                            //('acceleChange:',record);
                            this.handleCheckbox('accele',record)
                        }}
                    /></div>
                }
            },
            {
                title: (<div fieldid='includesub'>{this.state.json['20028001-000009']}</div>),/* 国际化处理： 包含下级*/
                dataIndex: "includesub",
                key: "includesub",
                width : 77,
                render: (text, record) => {
                    return <div fieldid='includesub' className='text-center'><Checkbox
                        checked={record.includesub === 'N' ? false : true}
                        disabled={
                            record.selectCell &&  record.selectCell.name != ''  ?
                                (record.searchRange === 'uapbd/refer/fiacc/AccountDefaultGridTreeRef/index' ? true : false)
                                : true
                        }
                        onChange={() => {
                            //('includesub:', record);
                            this.handleCheckbox('includesub',record)
                        }}
                    /></div>
                }
            }
        ];
        
        return (
            <div className='right_query'>
                <div className='query_body1'>
                    <div className='query_form gl-manageReport-modalDiv'>
    		<div>
                <Row className="row-margin">
                    <Col {...voucherHeightConfig.fourCol} className='gl-lineHeight-manageReport'>
                        <FormLabel isRequire={true} labelname={this.state.json['20028001-000029']}/>{/* 国际化处理： 核算账簿*/}
                    </Col>
                    <Col {...voucherHeightConfig.eightCol} className='gl-lineHeight-manageReport'>
                        <div className="book-ref">
                            {
                                createReferFn(
                                    this,
                                    {
                                        url: 'uapbd/refer/org/AccountBookTreeRef/index.js',
                                        value: this.state.accountingbook,
                                        referStateKey: 'checkAccountBook',
                                        referStateValue: this.state.checkAccountBook,
                                        stateValueKey: 'accountingbook',
                                        flag: true,
                                        queryCondition: {
                                            pk_accountingbook: this.state.accountingbook[0] && this.state.accountingbook[0].refpk
                                        }
                                    },
                                    {
                                        businessUnit: businessUnit ,
                                        getCheckContent: getCheckContent,
                                        renderTableFirstData: () => this.renderTableFirstData(9)
                                    },
                                    'assistPropertyBalance'
                                )
                            }
                        </div>
                    </Col>
                </Row>

                {/*启用科目版本：*/}
                <SubjectVersion
                    checked = {this.state.isversiondate}//复选框是否选中
                    data={this.state.versionDateArr}//
                    value={this.state.versiondate}
                    disabled={!this.state.isversiondate}
                    renderTableFirstData = {() => this.renderTableFirstData(9)}
                    handleValueChange = {(key, value) => this.handleValueChange(key, value, 'assistPropertyBalance', getCheckContent)}
                />

                <div className="modalTable">
                    <Table
                        columns={this.columns}
                        data={this.state.tableSourceData}
                        className='gl-table-nocheckbox'
                    />
                </div>

                {/*会计期间*/}
                <DateGroup
                    selectionState = {this.state.selectionState}
                    start = {this.state.start}
                    end = {this.state.end}
                    enddate = {this.state.enddate}
                    pk_accperiodscheme = {this.state.pk_accperiodscheme}
                    pk_accountingbook = {this.state.accountingbook[0]}
                    rangeDate = {this.state.rangeDate}
                    handleValueChange = {this.handleValueChange}
                    handleDateChange = {this.handleDateChange}
                    self = {this}
                    showRadio = {this.state.showRadio}
                />

                <Row className="row-margin">
                    <Col {...voucherHeightConfig.fourCol} className='gl-lineHeight-manageReport'>
                        <FormLabel labelname={this.state.json['20028001-000030']}/>{/* 国际化处理： 余额范围*/}
                    </Col>
                    <Col {...voucherHeightConfig.selectLabelCol} className='gl-lineHeight-manageReport'>

                        <div className="book-ref">
                            <Select
                                showClear={false}
                                fieldid='balanceori'
                                value={this.state.balanceori}
                                // style={{ width: 180, marginRight: 6 }}
                                onChange={this.handleBalanceoriChange.bind(this)}
                            >
                                <NCOption value={'-1'} key={'-1'} >{this.state.json['20028001-000031']}</NCOption>{/* 国际化处理： 双向*/}
                                <NCOption value={'0'} key={'0'} >{this.state.json['20028001-000032']}</NCOption>{/* 国际化处理： 借*/}
                                <NCOption value={'1'} key={'1'} >{this.state.json['20028001-000033']}</NCOption>{/* 国际化处理： 贷*/}
                                <NCOption value={'3'} key={'3'} >{this.state.json['20028001-000034']}</NCOption>{/* 国际化处理： 平*/}
                            </Select>
                        </div>
                    </Col>

                    <Col {...voucherHeightConfig.oneCol} className='gl-lineHeight-manageReport'></Col>
                    <Col {...voucherHeightConfig.halfCol} className='gl-lineHeight-manageReport'>
                        <Col {...voucherHeightConfig.tenCol} className='gl-lineHeight-manageReport'>
                            <NCNumber
                                fieldid='startBalance'
                                scale={4}
                                value={this.state.balanceMoneyLeft}
                                onChange={(value) => this.balanceMoney(value, 'balanceMoneyLeft')}
                            />

                        </Col>
                        {renderMiddleTxt()}
                        <Col {...voucherHeightConfig.tenCol} className='gl-lineHeight-manageReport'>
                            <NCNumber
                                fieldid='endBalance'
						        scale={4}
                                value={this.state.balanceMoneyRight}
                                onChange={(value) => this.balanceMoney(value, 'balanceMoneyRight')}
                            />
                        </Col>
                    </Col>
                </Row>

                {/*忽略日期选项*/}

                {/*包含凭证：*/}
                <CheckBoxCells
                    paramObj = {{
                        "noChargeVoucher": {//未记账凭证
                            show: true,
                            checked: this.state.includeuntally,
                            onChange: (value) => this.handleValueChange('includeuntally', value, 'assistAnalyzSearch')
                        },
                        "errorVoucher": {//错误凭证
                            show: true,
                            checked: this.state.includeerror,
                            onChange: (value) => this.handleValueChange('includeerror', value, 'assistAnalyzSearch')
                        },
                        "harmToBenefitVoucher": {//损益结转凭证
                            show: true,
                            checked: this.state.includeplcf,
                            onChange: (value) => this.handleValueChange('includeplcf', value, 'assistAnalyzSearch')
                        },
                        "againClassifyVoucher": {//重分类凭证
                            show: true,
                            checked: this.state.includerc,
                            onChange: (value) => this.handleValueChange('includerc', value, 'assistAnalyzSearch')
                        },
                    }}
                />


                {/*币种*/}
                {renderMoneyType(this.state.currtypeList,this.state.currtypeName, this.handleCurrtypeChange, this.state.json)}

                {/*返回币种：*/}
                {
                    returnMoneyType(
                        this,
                        {
                            key: 'selectedCurrValue',
                            value: this.state.selectedCurrValue,
                            groupEdit: this.state.groupCurrency,
                            gloableEdit: this.state.globalCurrency,
                            isManageReport:true
                        },
                        this.state.json
                    )
                }

                <FourCheckBox
                    totalTitle= {this.state.json['20028001-000018']} ///* 国际化处理： 显示*/
                    renderCells={
                        [
                            {
                                title: this.state.json['20028001-000019'],/* 国际化处理： 无发生不显示*/
                                checked: this.state.showzerooccur,
                                id: 'showzerooccur',
                                onChange: (value) => this.onChangeShowzerooccur(value, 'showzerooccur')
                            }
                        ]
                    }
                />

                <NewModal
                    modal = {this.props.modal}
                    title= {this.state.json['20028001-000020']} ///* 国际化处理： 属性选择*/
                    record={this.state.tableSourceData[this.state.page]}
                    closeNewModal = {this.closeNewModal}
                    sureHandle = {this.sureHandle}
                    sureText = {this.state.json['20028001-000021']} ///* 国际化处理： 确定 */
                    cancleText = {this.state.json['20028001-000014']} ///* 国际化处理： 取消*/
                    searchparam = {{buSecond, unitValueParam, accountingbook, isversiondate, versiondate, busiDate, json}}
                    json = {this.state.json}
                    NewModalRef = {init => this.NewModal = init}
                />
			</div>
                    </div>
                </div>
            </div>
		)
	}
    clickPlanEve = (value) => {
        clickPlanEve(this, value);
    }
    saveSearchPlan = () => {//点击《保存方案》按钮触发事件
        //('saveSearchPlan>>', this.state)
        return {...this.state}
    }
    clickSearchBtn = () => {//点击查询框的"查询"按钮事件
    	let pk_accountingbook = [];
		let pk_unit = [];
		let moneyLeft = Number(this.state.balanceMoneyLeft);
		let moneyRight = Number(this.state.balanceMoneyRight);
		//('moneyyyy::', moneyLeft,  moneyRight, moneyLeft < moneyRight)
		if(moneyLeft > moneyRight){
			toast({
				content: this.state.json['20028001-000022'],/* 国际化处理： 余额范围查询条件信息输入有误(起始值大于终止值或是为负值)！*/
				color: 'warning'
			});
			return;
		}
		let lastAssvos = [];
		this.state.tableSourceData.forEach((item)=>{
			//('assvos>>>',item);
			let resultObj = {};
			if(item.selectCell && item.selectCell.name && !item.selectCellAttr){
				resultObj.name = item.selectCell.name;
				resultObj.pk_checktype = item.selectCell.pk_checktype;
				resultObj.pk_checkvalue = Array.isArray(item.selectRange) ? item.selectRange.join(',') : item.selectRange;
				resultObj.headele = item.showLocal;
				resultObj.accele = item.accele;
				resultObj.includesub = item.includesub;
				lastAssvos.push(resultObj)
			} else if(item.selectCell && item.selectCell.name && item.selectCellAttr){
				resultObj.name = item.selectCell.name;
				resultObj.pk_checktype = item.selectCell.pk_checktype;
				resultObj.attr = [];
				resultObj.headele = item.showLocal;
				resultObj.accele = item.accele;
				resultObj.includesub = item.includesub;
				item.selectCellAttr.map((itemCell) => {
					if(itemCell.select){
						resultObj.attr.push(itemCell);
					}
				})
				lastAssvos.push(resultObj)
			}
		})
		//('lastAssvos>>', lastAssvos)
		if (Array.isArray(this.state.accountingbook)) {
			this.state.accountingbook.forEach(function (item) {
				pk_accountingbook.push(item.refpk)
			})
		}

		if (Array.isArray(this.state.buSecond)) {
			this.state.buSecond.forEach(function (item) {
				pk_unit.push(item.refpk)
			})
		}
		//
        //('new-pk_accountingbook:', pk_accountingbook);
        let data = {
            pk_accountingbook: pk_accountingbook,
            pk_unit,
            multbusi: this.state.multbusi,
            usesubjversion: this.state.isversiondate + '',// 使用科目版本
            versiondate: this.state.isversiondate ? this.state.versiondate : this.state.busiDate, //this.state.versiondate,//科目版本
            // pk_accasoa://条件框选择科目
            startcode: this.state.startcode.refpk,  //开始科目编码
            endcode: this.state.endcode.refpk,    //结束科目编码
            startlvl: this.state.startlvl,
            endlvl: this.state.endlvl,
            isleave: this.state.allLast ? 'Y' : 'N',
            isoutacc: this.state.isoutacc ? 'Y' : 'N',
            startyear: this.state.startyear,
            endyear: this.state.endyear,
            startperiod: this.state.startperiod,
            endperiod:   this.state.endperiod,

            startdate: this.state.rangeDate[0],
            enddate: this.state.rangeDate[1],

            //未记账、错误、损益结转、重分类  Y/N  注意：‘包含凭证’是个标题，后面的才是选项
            includeuntally: this.state.includeuntally ? 'Y' : 'N',
            includeerror: this.state.includeerror ? 'Y' : 'N',
            includeplcf: this.state.includeplcf ? 'Y' : 'N',
            includerc: this.state.includerc ? 'Y' : 'N',
            pk_currtype: this.state.currtype,
            returncurr: this.state.selectedCurrValue, //返回币种  1,2,3 组织,集团,全局
            mutibook: this.state.mutibook,
            showzerooccur: this.state.showzerooccur ? 'Y' : 'N',
            showzerobalanceoccur: this.state.showzerobalanceoccur ? 'Y' : 'N',
            currplusacc: this.state.currplusacc,
            sumbysubjtype: this.state.sumbysubjtype ? 'Y' : 'N',
            balanceori: this.state.balanceori,
            twowaybalance: this.state.twowaybalance ? 'Y' : 'N',
            istree: 'Y',
            ass: lastAssvos,
            rangefrom: this.state.balanceMoneyLeft,
            rangeto: this.state.balanceMoneyRight,
            querybyperiod: this.state.selectionState,//是选择会计期间还是日期
            appcode: this.state.appcode
        }
        
        let url = '/nccloud/gl/accountrep/checkparam.do'
        let flagShowOrHide;
        ajax({
            url,
            data,
            async: false,
            success: function (response) {
                flagShowOrHide = true
            },
            error: function (error) {
                flagShowOrHide = false
                toast({ content: error.message, color: 'warning' });
            }
        })
        if (flagShowOrHide == true) {
            this.props.onConfirm(data)
        } else if (flagShowOrHide == false) {
            return true;
        }
    }

	render() {
        let { search } = this.props;
        let { NCCreateSearch } = search;
        return <div>
            {
                NCCreateSearch(this.searchId, {
                    onlyShowSuperBtn:true,                       // 只显示高级按钮
                    superBtnFieldid: 'search', //自定义高级按钮fieldid
                    replaceSuperBtn:this.state.json['20028001-000013'],                      // 自定义替换高级按钮名称/* 国际化处理： 查询*/
                    replaceRightBody:this.renderModalList,
                    showAdvSetDefault: false,//高级里不要方案设置默认功能
                    hideSearchCondition:true,//隐藏《候选条件》只剩下《查询方案》
                    clickPlanEve:this.clickPlanEve ,            // 点击高级面板中的查询方案事件 ,用于业务组为自定义查询区赋值
                    saveSearchPlan:this.saveSearchPlan ,        // 保存查询方案确定按钮事件，用于业务组返回自定义的查询条件
                    oid:this.props.meta.oid,
                    clickSearchBtn: this.clickSearchBtn,  // 点击按钮事件
                    isSynInitAdvSearch: true,//渲染右边面板自定义区域
                })}
        </div>
	}
}

CentralConstructorModal = createPage({})(CentralConstructorModal)

export default CentralConstructorModal;

/*2S7LXljdWdGhrCxZ1MFl4i0/jcYg0CI/M/l35xRmsHHDM270ypZGxQFjXbKKRAXA*/